#!/usr/bin/env python2.7
from storm.locals import *
import datetime

class User(object):
    __storm_table__ = "user"
    id = Int(primary=True)
    email = Unicode()
    username = Unicode()
    password = Unicode()
    global_points = Int()

class Game(object):
    __storm_table__ = "game"
    id = Int(primary=True)
    max_step = Int()
    name = Unicode()
    start_time = DateTime()
    finish_time = DateTime()
    zone = Unicode()
    latitude = Float()
    longitude = Float()

class Participation(Storm):
    __storm_table__ = "participation"
    __storm_primary__ = "id_user", "id_game"
    id_user = Int()
    id_game = Int()
    score = Int()
    current_riddle = Int()
    user = Reference (id_user, "User.id")
    game = Reference (id_game, "Game.id")

class Riddle(Storm):
    __storm_table__ = "riddle"
    __storm_primary__ = "id", "id_location"
    id = Int()
    id_location = Int()
    text = Unicode()
    location = Reference (id_location, "Location.id")

class Location(Storm):
    __storm_table__ = "location"
    __storm_primary__ = "id", "id_game"
    id = Int()
    id_game = Int()
    name = Unicode()
    latitude = Float()
    longitude = Float()
    game = Reference (id_game, "Game.id")

class Historic(Storm):
    __storm_table__ = "historic"
    __storm_primary__ = "id_user", "id_location"
    id_user = Int()
    id_location = Int()
    timestamp = DateTime()
    proximity = Int()
    location = Reference (id_location, "Location.id")
    user = Reference (id_user, "User.id")

class GameInfo():
    def __init__(self, game_id, game_location, game_end_date, game_n_users):
        self.id = game_id
        self.zone = game_location
        self.finish_time = game_end_date
        self.n_users = game_n_users

class GameStatus():
    def __init__(self, username, location, score):
        self.username = username
        self.location = location
        self.score = score

class GameScores():
    def __init__(self, username, step, score):
        self.username = username
        self.step = step
        self.score = score

class RiddleInfo():
    def __init__(self, id_hint, text):
        self.id = id_hint
        self.text = text
